package team.seekers.skill.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import team.seekers.skill.entity.dao.UserSection;
import team.seekers.skill.entity.dao.UserSkill;
import team.seekers.skill.mapper.UserSkillMapper;
import team.seekers.skill.service.UserSkillService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;


/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author hbc
 * @since 2021-01-27
 */
@Service
public class UserSkillServiceImpl extends ServiceImpl<UserSkillMapper, UserSkill> implements UserSkillService {


    @Override
    public Integer getStatus(String userId, String skillId) {
        QueryWrapper<UserSkill> wrapper = new QueryWrapper<>();
        wrapper.eq("user_id",userId);
        wrapper.eq("skill_id",skillId);
        UserSkill userSkill = getOne(wrapper);
        if (userSkill == null)
            return 0;
        else
            return userSkill.getStatus();
    }

    @Override
    public boolean removeBySkillId(String skillId) {
        QueryWrapper<UserSkill> wrapper = new QueryWrapper<>();
        wrapper.eq("skill_id",skillId);
        boolean remove = remove(wrapper);
        return remove;
    }
}
